package com.mqtt.ctwingmqtt.domain.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.sql.Timestamp;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@TableName("command")
@ApiModel(description = "指令下发表实体类")
public class Command {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @ApiModelProperty(value = "主键ID", example = "1")
    @TableId(type = IdType.AUTO)
    private Long id;

    @Column(name = "device_address", nullable = false)
    @ApiModelProperty(value = "设备地址", example = "1")
    private String deviceAddress;

    @Column(name = "command_text", nullable = false, columnDefinition = "TEXT")
    @ApiModelProperty(value = "下发指令", example = "启动设备")
    private String commandText;

    @Column(name = "response_body", length = 100)
    @ApiModelProperty(value = "回复数据", example = "设备已启动")
    private String responseBody;

    @Column(name = "user_name", nullable = false)
    @ApiModelProperty(value = "用户ID（逻辑外键）", example = "1")
    private String userName;

    @Column(name = "send_status", nullable = false)
    @ApiModelProperty(value = "发送状态（如已发送/未发送）", example = "已发送")
    private String sendStatus;

    @Column(name = "command_id", nullable = false)
    @ApiModelProperty(value = "指令id", example = "1")
    private String commandId;

    @Column(name = "command_id", nullable = false)
    @ApiModelProperty(value = "产品id", example = "1")
    private Integer productId;

    @Column(name = "device_id", nullable = false)
    @ApiModelProperty(value = "设备id", example = "1")
    private String deviceId;

    @Column(name = "master_key", nullable = false)
    @TableField("master_key")
    @ApiModelProperty(value = "master_key", example = "1")
    private String masterKey;

    @Column(name = "create_time", nullable = false, updatable = false, insertable = false, columnDefinition = "DATETIME DEFAULT CURRENT_TIMESTAMP")
    @ApiModelProperty(value = "创建时间", example = "2023-10-01 12:34:56")
    private Timestamp createTime;

    @Column(name = "update_time", nullable = false, columnDefinition = "DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
    @ApiModelProperty(value = "更新时间", example = "2023-10-01 12:34:56")
    private Timestamp updateTime;


}